import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author Hanpeng
 * @date 2020/12/22 17:19
 * @description:
 */
public class TestMain {
    public static void main(String[] args) {
        long current = System.currentTimeMillis();
        int rawOffset = TimeZone.getDefault().getRawOffset();
        //28800000===>28800===>8小时
        System.out.println(current);
        //今天凌晨
        long l = current / (1000 * 3600 * 24) * (1000 * 3600 * 24);
        System.out.println(rawOffset);
        System.out.println(l);
        //1608629023795
        //1608595200000
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(l)));
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(current)));
        long zero = current / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
        Date dateZero = new Date(l);
        //时间可以设置时区么
        String s = dateZero.toGMTString();
        System.out.println(s);

        Calendar instance = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
        instance.setTime(dateZero);
        Date time = instance.getTime();
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time));

        SimpleDateFormat dateFormatfff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormatfff.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
        Date zeroDate = null;
        long l1 = current / (1000 * 3600 * 24) * (1000 * 3600 * 24);
        System.out.println("===> "+dateFormatfff.format(new Date(l1)));

    }
}
